import {NextRequest, NextResponse} from "next/server";
import {readFile} from "fs/promises";
import {read} from "fs";

export async function GET(req: NextRequest) {
    console.log(req.nextUrl.searchParams);
    let params = req.nextUrl.searchParams

    let c = params.get('c')
    let q = params.get('q')
    if (!c || !q) return NextResponse.error()

    let file = await readFile(`public/questions/${c}/${q}`, "utf-8")

    return NextResponse.json({msg: 'ok', data: file})
}

export async function POST(req: NextRequest) {
    let res =await req.json()
    console.log(res)


    return NextResponse.json({msg: 'ok'})
}